package com.luyuan.crm.user.web;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import com.luyuan.crm.user.PartyGroup;
import com.luyuan.crm.user.service.PartyGroupService;
import com.ruijie.web.jsf.provider.SelectItemsProvider;

@Component("partyGroupProvider")
public class PartyGroupProvider implements SelectItemsProvider {
    @Resource(name = "partyGroupService")
    private PartyGroupService partyGroupService;

    @Override
    public List<SelectItem> getSelectItems(Object... parameters) {
        List<PartyGroup> partyGroups = partyGroupService.getAll();

        List<SelectItem> items = new ArrayList<SelectItem>();
        for (PartyGroup partyGroup : partyGroups) {
            SelectItem item = new SelectItem(partyGroup, partyGroup.getPartyGroupName());
            items.add(item);
        }
        return items;
    }

}
